﻿using LeaRun.Application.Entity.BaseManage;
using LeaRun.Application.IService.BaseManage;
using LeaRun.Data.Repository;
using LeaRun.Util.WebControl;
using System;
using System.Collections.Generic;
using System.Linq;

namespace LeaRun.Application.Service.BaseManage
{
    /// <summary>
    /// 单表开发效果展示（学生）
    /// </summary>
    public class studentService : RepositoryFactory<studentEntity>, studentIService
    {
        /// <summary>
        /// 获取页数据
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public IEnumerable<studentEntity> GetPageList(Pagination pagination, string queryJson)
        {
            return base.BaseRepository().FindList(pagination);
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public IEnumerable<studentEntity> GetList(string queryJson)
        {
            return base.BaseRepository().IQueryable().ToList<studentEntity>();
        }
        /// <summary>
        /// 获取对象
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public studentEntity GetEntity(string keyValue)
        {
            return base.BaseRepository().FindEntity(keyValue);
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="keyValue"></param>
        public void RemoveForm(string keyValue)
        {
            base.BaseRepository().Delete(keyValue);
        }
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        public void SaveForm(string keyValue, studentEntity entity)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);
                base.BaseRepository().Update(entity);
                return;
            }
            entity.Create();
            base.BaseRepository().Insert(entity);
        }
    }
}
